import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { SuitAttrLockInfo } from "./SuitAttrLockInfo";
import { EquipmentUtil } from "../../common/util/EquipmentUtil";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { Alert } from "../../../../../com/mui/controls/Alert";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GButton } from "../../../../../com/mui/controls/GButton";
type int = number;
//class SuitAttrLockCellRenderer
    
    export  class SuitAttrLockCellRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._lockInfo = arg1 as SuitAttrLockInfo;
            if (this._lockInfo) 
            {
                this._lockTxt.htmlText = EquipmentUtil.getSuitTipByCode(this._lockInfo.suitCode, this._lockInfo.isLock);
                if (this._lockInfo.isLock) 
                {
                    this._lockBtn.label = Language.getString(35959);
                }
                else 
                {
                    this._lockBtn.label = Language.getString(35960);
                }
                this._lockBtn.drawNow();
                this._lockBtn.visible = true;
            }
            else 
            {
                this._lockTxt.htmlText = Language.getString(35962);
                this._lockBtn.visible = false;
            }
            return;
        }

        /* internal  */init(): void
        {
            this._lockTxt = ObjCreate.createTextField("", 0, 0, 178, 20, this);
            this._lockTxt.mouseWheelEnabled = false;
            this._lockTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._lockBtn = ObjCreate.createGButton("", 50, 150, 70, 24, this, "ButtonSpecial");
            this._lockBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onLockBtnClickHandler);
            return;
        }

        /* internal  */onLockBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var e: Object /* flash.events.MouseEvent */;
            var oper: string;
            var onClose: Function;

            var loc1;
            oper = null;
            e = arg1;
            if (this._lockInfo) 
            {
                onClose = (arg1: int): void
                {
                    if (arg1 == Alert.OK) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.LockSuit, {"suitCode": _lockInfo.suitCode, "doLock":!_lockInfo.isLock}));
                    }
                    return;
                }
                if (this._lockInfo.isLock) 
                {
                    oper = Language.getString(35959);
                }
                else 
                {
                    oper = Language.getString(35960);
                }
                Alert.show(Language.getStringByParam(35963, oper), null, Alert.OK | Alert.CANCEL, null, onClose);
            }
            return;
        }

        /* internal */ /* var */_lockTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_lockBtn: GButton;

        /* internal */ /* var */_lockInfo: SuitAttrLockInfo;
    }
